# 辅助函数

from script.get_contest_info.response.vj_response import vj_response
import json

# 对json表单中相关数据(uid,problem_id,time)进行转换
def get_user_id(contest_id,uid):
    data = json.loads(vj_response(contest_id))
    participants = data.get('participants', {})
    for user_id, info in participants.items():
        if info[0] == uid:
            return user_id
    return None


if __name__ == '__main__':
    uid_to_find = "C21725"
    result = get_user_id(648764, uid_to_find)
    if result:
        print(f"用户编号为: {result}")
    else:
        print(f"未找到对应 uid 的用户编号")
